import java.util.*;

/**
 * Created with IntelliJ IDEA
 * Description
 * User: 王杰
 * Date: 2025-05-26
 * Time: 21:02
 */
public class Test {
    public static void main(String[] args) {
        LinkedList<Integer> linkedList2 = new LinkedList<>();

        linkedList2.add(1);
        linkedList2.addLast(3);
        linkedList2.addLast(4);
        linkedList2.addLast(5);
        System.out.println(linkedList2);

        System.out.println("=========ListIterator=========");
        ListIterator<Integer> listIterator = linkedList2.listIterator(linkedList2.size());
        while (listIterator.hasPrevious()) {
            System.out.print(listIterator.previous() + " ");
        }
        System.out.println();

        System.out.println("=========ListIterator=========");
        ListIterator<Integer> listIterator1 = linkedList2.listIterator();
        while (listIterator1.hasNext()) {
            System.out.print(listIterator1.next() + " ");
        }
        System.out.println();

        System.out.println("=========Iterator=========");
        Iterator<Integer> iterator = linkedList2.iterator();
        while (iterator.hasNext()) {
            System.out.print(iterator.next() + " ");
        }
        System.out.println();

        System.out.println("=========for each=========");
        for (Integer x : linkedList2) {
            System.out.print(x + " ");
        }
        System.out.println();

        System.out.println("=========for=========");
        for (int i = 0; i < linkedList2.size(); i++) {
            System.out.print(linkedList2.get(i) + " ");
        }
        System.out.println();


    }
    public static void main2(String[] args) {
        List<Integer> linkedList1 = new LinkedList<>();
        LinkedList<Integer> linkedList2 = new LinkedList<>();

        linkedList2.add(1);
        linkedList2.addFirst(2);
        linkedList2.addLast(3);
        linkedList2.addLast(4);
        linkedList2.addLast(5);
        System.out.println(linkedList2);

        ArrayList<Integer> list = new ArrayList<>();
        list.add(11);
        list.add(21);
        list.add(31);
        linkedList2.addAll(list);
        System.out.println(linkedList2);
    }
    public static void main1(String[] args) {
        MySingleList mySingleList = new MySingleList();
        /*mySingleList.createList();
        mySingleList.display();
        System.out.println();

        mySingleList.addFirst(99);
        mySingleList.addLast(99);
        mySingleList.display();
        System.out.println();*/

        /*mySingleList.addFirst(99);
        mySingleList.addFirst(12);
        mySingleList.addFirst(23);
        mySingleList.addFirst(34);
        mySingleList.display();

        mySingleList.addIndex(0,199);
        mySingleList.addIndex(1,299);
        mySingleList.addIndex(6,699);*/

        mySingleList.addLast(1);
        mySingleList.addLast(2);
        mySingleList.addLast(3);
        mySingleList.addLast(4);
        mySingleList.addLast(5);

        mySingleList.remove(3);
        mySingleList.display();
        System.out.println();

        System.out.println("===================");
        mySingleList.clear();
        mySingleList.display();
    }
}
